package org.zoomdev.zoom.common.caster;

import org.zoomdev.zoom.common.json.JSON;

import java.lang.reflect.Type;

class String2Other implements ValueCaster {

    Type javaType;

    String2Other(Type javaType) {
        this.javaType = javaType;
    }

    @Override
    public Object to(Object src) {
        try {
            return JSON.parse((String) src, javaType);
        } catch (Exception e) {
            throw new CasterException(e);
        }
    }
}
